package com.example.java_websocket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.java_websocket.model.ChatHistory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface ChatHistoryMapper extends BaseMapper<ChatHistory> {
    @Insert("INSERT INTO chat_history (content) VALUES (#{message})")
    void insert(String message);

    // 查询所有聊天记录
    @Select("SELECT * FROM chat_history ORDER BY created_at")

    List<ChatHistory> selectAll();

}
